home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 08 - 1992 / 08.02 Jun 92 / Generic Virus Detection / FileOps.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-26  |  946 b   |  39 lines  |  [TEXT/MPS ]

  1. /* fileops.c : file operations for dynamic */
  2.  
  3. #include "dec.h"
  4. #include "errors.h"
  5.  
  6. char open_file(fp, operation)
  7. FILE **fp;
  8. char *operation;
  9. {
  10.   SFReply        reply;
  11.   char filename[BUFSIZ];
  12.   GetfileName(&reply);
  13.   strcpy(filename, (char *)reply.fName);
  14.   *fp = fopen(filename, operation);
  15.   if (!(reply.good)) {
  16.     fprintf(stderr, CANNOT_OPEN_FILE, filename);
  17.     exit_cleanly(NO_ERROR, EXIT_FAILURE); 
  18.   }
  19.   else return(TRUE);
  20. }
  21.  
  22. /* The following routines deal with the filea. This is all using the Macintosh HFS.    */
  23.  
  24. /* GetfileName: read a file name usign the HFS */
  25. GetfileName(reply)
  26. SFReply        *reply;
  27. {
  28.     Point    dlgPoint;
  29.     Str255 defName = "\pDynamic Output";
  30.     int    numTypes = 1;
  31.     dlgPoint.h = 100;    /* position of the             'open' dialog box */
  32.     dlgPoint.v    = 100;
  33.     SFPutFile (dlgPoint, "\pSave output file         as…", defName, NIL_POINTER, 
  34.          reply);
  35.     PtoCstr ((char *) (*reply).fName);    
  36.     /* convert from PASCAL to 'C' string */
  37. }    /* GetfileName */
  38.  
  39.